package edu.inf3.j2ee.config;

import java.util.HashMap;

public class Config {

	private HashMap<String, Object> map;

	public Config (){
		this.map = new HashMap<String, Object>();
	}
	
	@SuppressWarnings("unchecked")
	public void setMap (Object m){
		this.map = (HashMap<String, Object>)m;
	}
	
	public HashMap<String, Object> getMap (){
		return this.map;
	}
	
	public boolean addPropertie(String name, Object value){
		boolean result = true;
		
		if (this.has(name)){
			result = false;
		}
		else
		{
			this.map.put(name, value);
		}
		return result;
	}
	
	public int count (){
		return this.map.size();
	}
	
	public boolean has (String name){
		return (this.map.containsKey(name));
	}
	
	public int getIntegerPropertie (String name){
		Integer result = -1;
		
		if (this.has(name)){
			result = (Integer)this.map.get(name);
		}
		
		return result;
	}
	
	public float getFloatPropertie (String name){
		Float result = -1f;
		
		if (this.has(name)){
			result = (Float)this.map.get(name);
		}
		
		return result;
	}
	
	public long getLongPropertie (String name){
		Long result = -1l;
		
		if (this.has(name)){
			result = (Long)this.map.get(name);
		}
		
		return result;
	}
	
	public String getStringPropertie (String name){
		String result = "";
		
		if (this.has(name)){
			result = (String)this.map.get(name);
		}
		
		return result;
	}
	
	public boolean getBooleanPropertie (String name){
		Boolean result = null;
		
		if (this.has(name)){
			result = (Boolean)this.map.get(name);
		}
		
		return result;
	}
}
